<template>
  <div class="app-container p-rel">
    <div class="container-title">统计</div>
    <div>
      <div>
        数量统计： {{nurseCountDto.count}}
      </div>
      <div>
        多点执业护士统计：{{nurseCountDto.multiPointCount}}
        多点执业护士统计百分比：{{nurseCountDto.multiPointPercent}}
      </div>
      <div>
        多点执业未备案统计：{{nurseCountDto.notMultiPointCount}}
        多点执业未备案统计百分比：{{nurseCountDto.notMultiPointPercent}}
      </div>

    </div>

    <div class="container-title" style="margin-top: 20px">查询</div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="85px">
      <el-row :gutter="15">
        <el-col :lg="8" :xl="6">
          <el-form-item label="护士姓名" prop="nurseName">
            <el-input
              v-model="queryParams.nurseName"
              placeholder="请输入护士姓名"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="证件号码" prop="identityNumber">
            <el-input
              v-model="queryParams.identityNumber"
              placeholder="请输入证件号码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="执业注册证书编码" prop="certificateNumber" label-width="130px">
            <el-input
              v-model="queryParams.certificateNumber"
              placeholder="请输入执业注册证书编码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
            <el-button type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
            <el-button icon="" size="" @click="resetQuery">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-table v-loading="loading" :data="nurseList">
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column label="护士姓名" align="center" prop="nurseName" />
      <el-table-column label="证件号码" align="center" prop="identityNumber" />
      <el-table-column label="执业注册证书编码" align="center" prop="certificateNumber" />
      <el-table-column label="主要医疗机构" align="center" prop="dainong" />
      <el-table-column label="联系电话" align="center" prop="phonenumber" />
      <el-table-column label="护士执业注册时间" align="center" prop="registerTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="多点执业是否注册" align="center" prop="multiPoint">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.multi_point_type" :value="scope.row.multiPoint"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="selectQuery(scope.row)"
          >查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listNurse, getNurseCount, getNurseById } from "@/api/zhangping/nurse";
export default {
  name: "Nurse",
  dicts: ['multi_point_type', 'sys_user_sex'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 护士表格数据
      nurseList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        nurseName: null,
        identityNumber: null,
        certificateNumber: null,
        enterpriseName: null,
        creditCode: null,
        phonenumber: null,
        registerTime: null,
        multiPoint: null,
        photo: null,
        sex: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      detailForm:{},
      isEdit:false,
      editVisible:false,
      nurseCountDto:{
        //数量统计
        count: '',
        //点执业护士统计
        multiPointCount: '',
        //多点执业护士统计百分比
        multiPointPercent: '',
        //多点执业未备案统计
        notMultiPointCount: '',
        //多点执业未备案统计百分比
        notMultiPointPercent: '',
      }
    };
  },
  created() {
    this.getList();
    this.getNurseCount();
  },
  methods: {
    /** 查询护士列表 */
    getList() {
      this.loading = true;
      listNurse(this.queryParams).then(response => {
        this.nurseList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 查询护士执业注册信息列表统计 */
    getNurseCount() {
      getNurseCount().then(response => {
        this.nurseCountDto = response.data
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        nurseName: null,
        identityNumber: null,
        certificateNumber: null,
        enterpriseName: null,
        creditCode: null,
        phonenumber: null,
        registerTime: null,
        multiPoint: null,
        photo: null,
        sex: null,
        createId: null,
        createBy: null,
        createTime: null,
        updateId: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 查看详情
    selectQuery(row){
      getNurseById({id: row.id}).then(response => {
        console.log("response", response)
      });
      const obj = {
        path: '/zp/nurse/detail',
        query: {
          id: row.id
        }
      }
      this.$router.push(obj);
    }
  }
};
</script>
